.class public Lde/dealdoktor/app/activities/PostListing;
.super Lde/dealdoktor/app/activities/SuperListing;
.source "PostListing.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lde/dealdoktor/app/activities/PostListing$GetPostsTask;
    }
.end annotation


# instance fields
.field private broadcastReceiver:Landroid/content/BroadcastReceiver;


# direct methods
.method public constructor <init>()V
    .locals 1

    .prologue
    .line 29
    invoke-direct {p0}, Lde/dealdoktor/app/activities/SuperListing;-><init>()V

    .line 31
    new-instance v0, Lde/dealdoktor/app/activities/PostListing$1;

    invoke-direct {v0, p0}, Lde/dealdoktor/app/activities/PostListing$1;-><init>(Lde/dealdoktor/app/activities/PostListing;)V

    iput-object v0, p0, Lde/dealdoktor/app/activities/PostListing;->broadcastReceiver:Landroid/content/BroadcastReceiver;

    .line 29
    return-void
.end method

.method static synthetic access$0(Lde/dealdoktor/app/activities/PostListing;)V
    .locals 0
    .parameter

    .prologue
    .line 194
    invoke-direct {p0}, Lde/dealdoktor/app/activities/PostListing;->refresh()V

    return-void
.end method

.method private getAvailableCategories(Landroid/content/Context;)Ljava/util/ArrayList;
    .locals 13
    .parameter "c"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Landroid/content/Context;",
            ")",
            "Ljava/util/ArrayList",
            "<",
            "Lde/dealdoktor/app/data/CategoriesDAO;",
            ">;"
        }
    .end annotation

    .prologue
    const/4 v10, 0x0

    const/4 v9, 0x1

    .line 221
    new-instance v1, Ljava/util/ArrayList;

    invoke-direct {v1}, Ljava/util/ArrayList;-><init>()V

    .line 222
    .local v1, categories:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lde/dealdoktor/app/data/CategoriesDAO;>;"
    new-instance v2, Lde/dealdoktor/app/db/BaseModel;

    const-string v11, "categories"

    invoke-direct {v2, p1, v11}, Lde/dealdoktor/app/db/BaseModel;-><init>(Landroid/content/Context;Ljava/lang/String;)V

    .line 224
    .local v2, categoriesModel:Lde/dealdoktor/app/db/BaseModel;
    invoke-virtual {v2}, Lde/dealdoktor/app/db/BaseModel;->getAll()Landroid/database/Cursor;

    move-result-object v3

    .line 226
    .local v3, cursor:Landroid/database/Cursor;
    invoke-interface {v3}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v11

    if-eqz v11, :cond_5

    .line 228
    :cond_0
    const-string v11, "parent"

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v11

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getInt(I)I

    move-result v7

    .line 229
    .local v7, parent:I
    const-string v11, "id"

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v11

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getInt(I)I

    move-result v5

    .line 230
    .local v5, id:I
    const-string v11, "title"

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v11

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v8

    .line 231
    .local v8, title:Ljava/lang/String;
    const-string v11, "title"

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v11

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v4

    .line 232
    .local v4, description:Ljava/lang/String;
    const-string v11, "selected"

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v11

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getInt(I)I

    move-result v11

    if-ne v11, v9, :cond_6

    move v6, v9

    .line 234
    .local v6, isSelected:Z
    :goto_0
    if-nez v7, :cond_1

    .line 235
    new-instance v11, Lde/dealdoktor/app/data/CategoriesDAO;

    invoke-direct {v11, v5, v8, v4, v6}, Lde/dealdoktor/app/data/CategoriesDAO;-><init>(ILjava/lang/String;Ljava/lang/String;Z)V

    invoke-virtual {v1, v11}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 237
    :cond_1
    invoke-interface {v3}, Landroid/database/Cursor;->moveToNext()Z

    move-result v11

    .line 227
    if-nez v11, :cond_0

    .line 239
    invoke-interface {v3}, Landroid/database/Cursor;->moveToFirst()Z

    .line 241
    :cond_2
    const-string v11, "parent"

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v11

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getInt(I)I

    move-result v7

    .line 242
    const-string v11, "id"

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v11

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getInt(I)I

    move-result v5

    .line 243
    const-string v11, "title"

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v11

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v8

    .line 244
    const-string v11, "title"

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v11

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v4

    .line 245
    const-string v11, "selected"

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v11

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getInt(I)I

    move-result v11

    if-ne v11, v9, :cond_7

    move v6, v9

    .line 247
    :goto_1
    if-eqz v7, :cond_4

    .line 248
    invoke-virtual {v1}, Ljava/util/ArrayList;->iterator()Ljava/util/Iterator;

    move-result-object v11

    :cond_3
    invoke-interface {v11}, Ljava/util/Iterator;->hasNext()Z

    move-result v12

    if-nez v12, :cond_8

    .line 255
    :cond_4
    :goto_2
    invoke-interface {v3}, Landroid/database/Cursor;->moveToNext()Z

    move-result v11

    .line 240
    if-nez v11, :cond_2

    .line 257
    .end local v4           #description:Ljava/lang/String;
    .end local v5           #id:I
    .end local v6           #isSelected:Z
    .end local v7           #parent:I
    .end local v8           #title:Ljava/lang/String;
    :cond_5
    return-object v1

    .restart local v4       #description:Ljava/lang/String;
    .restart local v5       #id:I
    .restart local v7       #parent:I
    .restart local v8       #title:Ljava/lang/String;
    :cond_6
    move v6, v10

    .line 232
    goto :goto_0

    .restart local v6       #isSelected:Z
    :cond_7
    move v6, v10

    .line 245
    goto :goto_1

    .line 248
    :cond_8
    invoke-interface {v11}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lde/dealdoktor/app/data/CategoriesDAO;

    .line 249
    .local v0, cat:Lde/dealdoktor/app/data/CategoriesDAO;
    iget v12, v0, Lde/dealdoktor/app/data/CategoriesDAO;->id:I

    if-ne v12, v7, :cond_3

    .line 250
    iget-object v11, v0, Lde/dealdoktor/app/data/CategoriesDAO;->subCategories:Ljava/util/ArrayList;

    new-instance v12, Lde/dealdoktor/app/data/CategoriesDAO;

    invoke-direct {v12, v5, v8, v4, v6}, Lde/dealdoktor/app/data/CategoriesDAO;-><init>(ILjava/lang/String;Ljava/lang/String;Z)V

    invoke-virtual {v11, v12}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    goto :goto_2
.end method

.method private refresh()V
    .locals 4

    .prologue
    const/4 v3, 0x1

    const/4 v2, 0x0

    .line 196
    sput-boolean v2, Lde/dealdoktor/app/App;->updateIndex:Z

    .line 197
    sput v3, Lde/dealdoktor/app/App;->postsCurrentPage:I

    .line 198
    new-instance v0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;

    new-instance v1, Ljava/lang/ref/WeakReference;

    invoke-direct {v1, p0}, Ljava/lang/ref/WeakReference;-><init>(Ljava/lang/Object;)V

    invoke-direct {v0, v1, v3}, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;-><init>(Ljava/lang/ref/WeakReference;Z)V

    new-array v1, v2, [Ljava/lang/String;

    invoke-virtual {v0, v1}, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->execute([Ljava/lang/Object;)Landroid/os/AsyncTask;

    .line 200
    return-void
.end method


# virtual methods
.method public onCreate(Landroid/os/Bundle;)V
    .locals 4
    .parameter "savedInstanceState"

    .prologue
    const/4 v3, 0x1

    .line 40
    invoke-super {p0, p1}, Lde/dealdoktor/app/activities/SuperListing;->onCreate(Landroid/os/Bundle;)V

    .line 41
    const v0, 0x7f030006

    invoke-virtual {p0, v0}, Lde/dealdoktor/app/activities/PostListing;->setContentView(I)V

    .line 42
    invoke-direct {p0, p0}, Lde/dealdoktor/app/activities/PostListing;->getAvailableCategories(Landroid/content/Context;)Ljava/util/ArrayList;

    move-result-object v0

    sput-object v0, Lde/dealdoktor/app/App;->categories:Ljava/util/ArrayList;

    .line 43
    sget-object v0, Lde/dealdoktor/app/App;->posts:Ljava/util/ArrayList;

    invoke-virtual {v0}, Ljava/util/ArrayList;->clear()V

    .line 44
    sput v3, Lde/dealdoktor/app/App;->postsCurrentPage:I

    .line 46
    invoke-virtual {p0}, Lde/dealdoktor/app/activities/PostListing;->getParent()Landroid/app/Activity;

    move-result-object v0

    invoke-virtual {v0}, Landroid/app/Activity;->getParent()Landroid/app/Activity;

    move-result-object v0

    check-cast v0, Lde/dealdoktor/app/activities/Tabs;

    iput-object v0, p0, Lde/dealdoktor/app/activities/PostListing;->tabs:Lde/dealdoktor/app/activities/Tabs;

    .line 49
    const v0, 0x7f0b0009

    invoke-virtual {p0, v0}, Lde/dealdoktor/app/activities/PostListing;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/ListView;

    iput-object v0, p0, Lde/dealdoktor/app/activities/PostListing;->results:Landroid/widget/ListView;

    .line 52
    iget-object v0, p0, Lde/dealdoktor/app/activities/PostListing;->results:Landroid/widget/ListView;

    iget-object v1, p0, Lde/dealdoktor/app/activities/PostListing;->loadingView:Landroid/view/View;

    invoke-virtual {v0, v1}, Landroid/widget/ListView;->addFooterView(Landroid/view/View;)V

    .line 55
    new-instance v0, Lde/dealdoktor/app/adapter/PostListAdapter;

    sget-object v1, Lde/dealdoktor/app/App;->posts:Ljava/util/ArrayList;

    iget-object v2, p0, Lde/dealdoktor/app/activities/PostListing;->results:Landroid/widget/ListView;

    invoke-direct {v0, v1, p0, v2}, Lde/dealdoktor/app/adapter/PostListAdapter;-><init>(Ljava/util/ArrayList;Lde/dealdoktor/app/activities/SuperListing;Landroid/widget/ListView;)V

    iput-object v0, p0, Lde/dealdoktor/app/activities/PostListing;->listAdapter:Lde/dealdoktor/app/adapter/PostListAdapter;

    .line 56
    iget-object v0, p0, Lde/dealdoktor/app/activities/PostListing;->results:Landroid/widget/ListView;

    iget-object v1, p0, Lde/dealdoktor/app/activities/PostListing;->listAdapter:Lde/dealdoktor/app/adapter/PostListAdapter;

    invoke-virtual {v0, v1}, Landroid/widget/ListView;->setAdapter(Landroid/widget/ListAdapter;)V

    .line 59
    iget-object v0, p0, Lde/dealdoktor/app/activities/PostListing;->results:Landroid/widget/ListView;

    new-instance v1, Lde/dealdoktor/app/activities/PostListing$2;

    invoke-direct {v1, p0}, Lde/dealdoktor/app/activities/PostListing$2;-><init>(Lde/dealdoktor/app/activities/PostListing;)V

    invoke-virtual {v0, v1}, Landroid/widget/ListView;->setOnItemClickListener(Landroid/widget/AdapterView$OnItemClickListener;)V

    .line 68
    new-instance v0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;

    new-instance v1, Ljava/lang/ref/WeakReference;

    invoke-direct {v1, p0}, Ljava/lang/ref/WeakReference;-><init>(Ljava/lang/Object;)V

    invoke-direct {v0, v1, v3}, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;-><init>(Ljava/lang/ref/WeakReference;Z)V

    const/4 v1, 0x0

    new-array v1, v1, [Ljava/lang/String;

    invoke-virtual {v0, v1}, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->execute([Ljava/lang/Object;)Landroid/os/AsyncTask;

    .line 72
    iget-object v0, p0, Lde/dealdoktor/app/activities/PostListing;->results:Landroid/widget/ListView;

    new-instance v1, Lde/dealdoktor/app/activities/PostListing$3;

    invoke-direct {v1, p0}, Lde/dealdoktor/app/activities/PostListing$3;-><init>(Lde/dealdoktor/app/activities/PostListing;)V

    invoke-virtual {v0, v1}, Landroid/widget/ListView;->setOnScrollListener(Landroid/widget/AbsListView$OnScrollListener;)V

    .line 90
    return-void
.end method

.method protected onPause()V
    .locals 1

    .prologue
    .line 213
    invoke-super {p0}, Lde/dealdoktor/app/activities/SuperListing;->onPause()V

    .line 214
    iget-object v0, p0, Lde/dealdoktor/app/activities/PostListing;->broadcastReceiver:Landroid/content/BroadcastReceiver;

    invoke-virtual {p0, v0}, Lde/dealdoktor/app/activities/PostListing;->unregisterReceiver(Landroid/content/BroadcastReceiver;)V

    .line 215
    return-void
.end method

.method protected onResume()V
    .locals 3

    .prologue
    .line 204
    invoke-super {p0}, Lde/dealdoktor/app/activities/SuperListing;->onResume()V

    .line 205
    iget-object v0, p0, Lde/dealdoktor/app/activities/PostListing;->broadcastReceiver:Landroid/content/BroadcastReceiver;

    new-instance v1, Landroid/content/IntentFilter;

    const-string v2, "de.dealdoktor.broadcastaction.update"

    invoke-direct {v1, v2}, Landroid/content/IntentFilter;-><init>(Ljava/lang/String;)V

    invoke-virtual {p0, v0, v1}, Lde/dealdoktor/app/activities/PostListing;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

    .line 206
    sget-boolean v0, Lde/dealdoktor/app/App;->updateIndex:Z

    if-eqz v0, :cond_0

    .line 207
    invoke-direct {p0}, Lde/dealdoktor/app/activities/PostListing;->refresh()V

    .line 209
    :cond_0
    return-void
.end method

.method public onSearchRequested()Z
    .locals 1

    .prologue
    .line 191
    invoke-virtual {p0}, Lde/dealdoktor/app/activities/PostListing;->getParent()Landroid/app/Activity;

    move-result-object v0

    invoke-virtual {v0}, Landroid/app/Activity;->getParent()Landroid/app/Activity;

    move-result-object v0

    invoke-virtual {v0}, Landroid/app/Activity;->onSearchRequested()Z

    move-result v0

    return v0
.end method
